﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QuizEngine.Data;

namespace QuizEngine.Presentation
{
    public partial class QuizEngine : Form
    {
        Quiz _quiz;
        public QuizEngine()
        {
            InitializeComponent();
        }

        private void lblOpenChoiceQuizDialog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ChoiceQuiz choiceQuizDialog = new ChoiceQuiz();
            choiceQuizDialog.passSender = new ChoiceQuiz.PassSender(getQuiz);
            if (choiceQuizDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                showQuestion();
            }
        }

        private void getQuiz(object sender)
        {
            _quiz = (Quiz)sender;
        }

        private void showQuestion()
        {
            this.lblQuizName.Text = _quiz.QuizName;
            List<Question> test = new List<Question>();
            /*
             * */
            panel1.Controls.Clear();
            panel1.Controls.Add(new QuestionControl(test));
        }

        private void QuizEngine_Load(object sender, EventArgs e)
        {
            this.lblQuizName.Text = "";
            QuizEngineEntities qeEnt = new QuizEngineEntities();
            var q = qeEnt.Quizzes.Find(1);
            QuizEngineEntities qeEnt2 = new QuizEngineEntities();
            var h = qeEnt2.Quizzes.Find(1);
            var r = qeEnt.Quizzes.Find(1);
            qeEnt.Quizzes.Find(1).Add(new Quiz());
            qeEnt.Quizzes.Where(p => p.QuizName == "2");
            MessageBox.Show(q.QuizName);
        }
    }
}
